<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="utf-8">
<!-- abstractwidgetbox.cpp -->
  <title>QDesignerWidgetBoxInterface Class | Qt Designer Manual</title>
  <link rel="stylesheet" type="text/css" href="style/offline-simple.css" />
  <script type="text/javascript">
    document.getElementsByTagName("link").item(0).setAttribute("href", "style/offline.css");
    // loading style sheet breaks anchors that were jumped to before
    // so force jumping to anchor again
    setTimeout(function() {
        var anchor = location.hash;
        // need to jump to different anchor first (e.g. none)
        location.hash = "#";
        setTimeout(function() {
            location.hash = anchor;
        }, 0);
    }, 0);
  </script>
</head>
<body>
<div class="header" id="qtdocheader">
  <div class="main">
    <div class="main-rounded">
      <div class="navigationbar">
        <table><tr>
<td ><a href="../qtdoc/index.html">Qt 5.14</a></td><td ><a href="qtdesigner-manual.html">Qt Designer Manual</a></td><td ><a href="qtdesigner-module.html">C++ Classes</a></td><td >QDesignerWidgetBoxInterface</td></tr></table><table class="buildversion"><tr>
<td id="buildversion" width="100%" align="right"><a href="qtdesigner-manual.html">Qt 5.14.2 Reference Documentation</a></td>
        </tr></table>
      </div>
    </div>
<div class="content">
<div class="line">
<div class="content mainContent">
<div class="sidebar">
<div class="toc">
<h3><a name="toc">Contents</a></h3>
<ul>
<li class="level1"><a href="#public-functions">Public Functions</a></li>
<li class="level1"><a href="#details">Detailed Description</a></li>
</ul>
</div>
<div class="sidebar-content" id="sidebar-content"></div></div>
<h1 class="title">QDesignerWidgetBoxInterface Class</h1>
<!-- $$$QDesignerWidgetBoxInterface-brief -->
<p>The QDesignerWidgetBoxInterface class allows you to control the contents of Qt Designer's widget box. <a href="#details">More...</a></p>
<!-- @@@QDesignerWidgetBoxInterface -->
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> Header:</td><td class="memItemRight bottomAlign">   <span class="preprocessor">#include &lt;QDesignerWidgetBoxInterface&gt;</span>
</td></tr><tr><td class="memItemLeft rightAlign topAlign"> qmake:</td><td class="memItemRight bottomAlign"> QT += designer</td></tr><tr><td class="memItemLeft rightAlign topAlign"> Inherits:</td><td class="memItemRight bottomAlign"> <a href="../qtwidgets/qwidget.html">QWidget</a></td></tr></table></div><ul>
<li><a href="qdesignerwidgetboxinterface-members.html">List of all members, including inherited members</a></li>
</ul>
<a name="public-functions"></a>
<h2 id="public-functions">Public Functions</h2>
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qdesignerwidgetboxinterface.html#QDesignerWidgetBoxInterface">QDesignerWidgetBoxInterface</a></b>(QWidget *<i>parent</i> = nullptr, Qt::WindowFlags <i>flags</i> = Qt::WindowFlags())</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> virtual </td><td class="memItemRight bottomAlign"><b><a href="qdesignerwidgetboxinterface.html#dtor.QDesignerWidgetBoxInterface">~QDesignerWidgetBoxInterface</a></b>()</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> virtual QString </td><td class="memItemRight bottomAlign"><b><a href="qdesignerwidgetboxinterface.html#fileName">fileName</a></b>() const = 0</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> virtual bool </td><td class="memItemRight bottomAlign"><b><a href="qdesignerwidgetboxinterface.html#load">load</a></b>() = 0</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> virtual bool </td><td class="memItemRight bottomAlign"><b><a href="qdesignerwidgetboxinterface.html#save">save</a></b>() = 0</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> virtual void </td><td class="memItemRight bottomAlign"><b><a href="qdesignerwidgetboxinterface.html#setFileName">setFileName</a></b>(const QString &amp;<i>fileName</i>) = 0</td></tr>
</table></div>
<a name="details"></a>
<!-- $$$QDesignerWidgetBoxInterface-description -->
<div class="descr">
<h2 id="details">Detailed Description</h2>
<p>QDesignerWidgetBoxInterface contains a collection of functions that is typically used to manipulate the contents of <i>Qt Designer</i>'s widget box.</p>
<p><i>Qt Designer</i> uses an XML file to populate its widget box. The name of that file is one of the widget box's properties, and you can retrieve it using the <a href="qdesignerwidgetboxinterface.html#fileName">fileName</a>() function.</p>
<p>QDesignerWidgetBoxInterface also provides the <a href="qdesignerwidgetboxinterface.html#save">save</a>() function that saves the contents of the widget box in the file specified by the widget box's file name property. If you have made changes to the widget box, for example by dropping a widget into the widget box, without calling the <a href="qdesignerwidgetboxinterface.html#save">save</a>() function, the original content can be restored by a simple invocation of the <a href="qdesignerwidgetboxinterface.html#load">load</a>() function:</p>
<pre class="cpp">

          <span class="type"><a href="qdesignerwidgetboxinterface.html#QDesignerWidgetBoxInterface">QDesignerWidgetBoxInterface</a></span> <span class="operator">*</span>widgetBox <span class="operator">=</span> <span class="number">0</span>:
          widgetBox <span class="operator">=</span> formEditor<span class="operator">-</span><span class="operator">&gt;</span>widgetBox();

          widgetBox<span class="operator">-</span><span class="operator">&gt;</span>load();

</pre>
<p>The QDesignerWidgetBoxInterface class is not intended to be instantiated directly. You can retrieve an interface to Qt Designer's widget box using the <a href="qdesignerformeditorinterface.html#widgetBox">QDesignerFormEditorInterface::widgetBox</a>() function. A pointer to <i>Qt Designer</i>'s current <a href="qdesignerformeditorinterface.html">QDesignerFormEditorInterface</a> object (<code>formEditor</code> in the example above) is provided by the <a href="qdesignercustomwidgetinterface.html#initialize">QDesignerCustomWidgetInterface::initialize</a>() function's parameter. When implementing a custom widget plugin, you must subclass the <a href="qdesignercustomwidgetinterface.html">QDesignerCustomWidgetInterface</a> to expose your plugin to <i>Qt Designer</i>.</p>
<p>If you want to save your changes, and at the same time preserve the original contents, you can use the <a href="qdesignerwidgetboxinterface.html#save">save</a>() function combined with the <a href="qdesignerwidgetboxinterface.html#setFileName">setFileName</a>() function to save your changes into another file. Remember to store the name of the original file first:</p>
<pre class="cpp">

          <span class="type"><a href="../qtcore/qstring.html">QString</a></span> originalFile <span class="operator">=</span> widgetBox<span class="operator">-</span><span class="operator">&gt;</span>fileName();

          widgetBox<span class="operator">-</span><span class="operator">&gt;</span>setFileName(<span class="string">&quot;myWidgetBox.xml&quot;</span>);
          widgetBox<span class="operator">-</span><span class="operator">&gt;</span>save();

</pre>
<p>Then you can restore the original contents of the widget box by resetting the file name to the original file and calling <a href="qdesignerwidgetboxinterface.html#load">load</a>():</p>
<pre class="cpp">

          widgetBox<span class="operator">-</span><span class="operator">&gt;</span>setFileName(originalFile);
          widgetBox<span class="operator">-</span><span class="operator">&gt;</span>load();

</pre>
<p>In a similar way, you can later use your customized XML file:</p>
<pre class="cpp">

          <span class="keyword">if</span> (widgetBox<span class="operator">-</span><span class="operator">&gt;</span>filename() <span class="operator">!</span><span class="operator">=</span> <span class="string">&quot;myWidgetBox.xml&quot;</span>) {
              widgetBox<span class="operator">-</span><span class="operator">&gt;</span>setFileName(<span class="string">&quot;myWidgetBox.xml&quot;</span>);
              widgetBox<span class="operator">-</span><span class="operator">&gt;</span>load();
          }

</pre>
</div>
<p><b>See also </b><a href="qdesignerformeditorinterface.html">QDesignerFormEditorInterface</a>.</p>
<!-- @@@QDesignerWidgetBoxInterface -->
<div class="func">
<h2>Member Function Documentation</h2>
<!-- $$$QDesignerWidgetBoxInterface[overload1]$$$QDesignerWidgetBoxInterfaceQWidget*Qt::WindowFlags -->
<h3 class="fn" id="QDesignerWidgetBoxInterface"><a name="QDesignerWidgetBoxInterface"></a>QDesignerWidgetBoxInterface::<span class="name">QDesignerWidgetBoxInterface</span>(<span class="type"><a href="../qtwidgets/qwidget.html#QWidget">QWidget</a></span> *<i>parent</i> = nullptr, <span class="type"><a href="../qtcore/qt.html#WindowType-enum">Qt::WindowFlags</a></span> <i>flags</i> = Qt::WindowFlags())</h3>
<p>Constructs a widget box interface with the given <i>parent</i> and the specified window <i>flags</i>.</p>
<!-- @@@QDesignerWidgetBoxInterface -->
<!-- $$$~QDesignerWidgetBoxInterface[overload1]$$$~QDesignerWidgetBoxInterface -->
<h3 class="fn" id="dtor.QDesignerWidgetBoxInterface"><a name="dtor.QDesignerWidgetBoxInterface"></a><code>[virtual] </code>QDesignerWidgetBoxInterface::<span class="name">~QDesignerWidgetBoxInterface</span>()</h3>
<p>Destroys the widget box interface.</p>
<!-- @@@~QDesignerWidgetBoxInterface -->
<!-- $$$fileName[overload1]$$$fileName -->
<h3 class="fn" id="fileName"><a name="fileName"></a><code>[pure virtual] </code><span class="type"><a href="../qtcore/qstring.html">QString</a></span> QDesignerWidgetBoxInterface::<span class="name">fileName</span>() const</h3>
<p>Returns the name of the XML file <i>Qt Designer</i> is currently using to populate its widget box.</p>
<p><b>See also </b><a href="qdesignerwidgetboxinterface.html#setFileName">setFileName</a>().</p>
<!-- @@@fileName -->
<!-- $$$load[overload1]$$$load -->
<h3 class="fn" id="load"><a name="load"></a><code>[pure virtual] </code><span class="type">bool</span> QDesignerWidgetBoxInterface::<span class="name">load</span>()</h3>
<p>Populates <i>Qt Designer</i>'s widget box by loading (or reloading) the currently specified XML file. Returns true if the file is successfully loaded; otherwise false.</p>
<p><b>See also </b><a href="qdesignerwidgetboxinterface.html#setFileName">setFileName</a>().</p>
<!-- @@@load -->
<!-- $$$save[overload1]$$$save -->
<h3 class="fn" id="save"><a name="save"></a><code>[pure virtual] </code><span class="type">bool</span> QDesignerWidgetBoxInterface::<span class="name">save</span>()</h3>
<p>Saves the contents of <i>Qt Designer</i>'s widget box in the file specified by the <a href="qdesignerwidgetboxinterface.html#fileName">fileName</a>() function. Returns true if the content is successfully saved; otherwise false.</p>
<p><b>See also </b><a href="qdesignerwidgetboxinterface.html#fileName">fileName</a>() and <a href="qdesignerwidgetboxinterface.html#setFileName">setFileName</a>().</p>
<!-- @@@save -->
<!-- $$$setFileName[overload1]$$$setFileNameconstQString& -->
<h3 class="fn" id="setFileName"><a name="setFileName"></a><code>[pure virtual] </code><span class="type">void</span> QDesignerWidgetBoxInterface::<span class="name">setFileName</span>(const <span class="type"><a href="../qtcore/qstring.html">QString</a></span> &amp;<i>fileName</i>)</h3>
<p>Sets the XML file that <i>Qt Designer</i> will use to populate its widget box, to <i>fileName</i>. You must call <a href="qdesignerwidgetboxinterface.html#load">load</a>() to update the widget box with the new XML file.</p>
<p><b>See also </b><a href="qdesignerwidgetboxinterface.html#fileName">fileName</a>() and <a href="qdesignerwidgetboxinterface.html#load">load</a>().</p>
<!-- @@@setFileName -->
</div>
        </div>
       </div>
   </div>
   </div>
</div>
<div class="footer">
   <p>
   <acronym title="Copyright">&copy;</acronym> 2020 The Qt Company Ltd.
   Documentation contributions included herein are the copyrights of
   their respective owners.<br/>    The documentation provided herein is licensed under the terms of the    <a href="http://www.gnu.org/licenses/fdl.html">GNU Free Documentation    License version 1.3</a> as published by the Free Software Foundation.<br/>    Qt and respective logos are trademarks of The Qt Company Ltd.     in Finland and/or other countries worldwide. All other trademarks are property
   of their respective owners. </p>
</div>
</body>
</html>
